Visual Studio builds: Add optional rules to generate translations
authorChun-wei Fan <fanchunwei@src.gnome.org>
Thu, 16 Jun 2022 10:31:37 +0000 (18:31 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Thu, 16 Jun 2022 10:42:16 +0000 (18:42 +0800)
Add a target in the install-msvc.mak file that enables one to generate
the translations (.mo) files using msgfmt from the .po catalog files.

Add an entry in config-msvc.mak[.in] so that one can use it to configure
a custom location for the msgfmt.exe program, since it is harder to
install with Visual Studio, so that one can use a prebuilt copy from
Cygwin or MSYS2, for instance.

win32/README_FEATURES_MSVC.txt
win32/config-msvc.mak.in
win32/install-msvc.mak

index 2a37aea19f7a9c3bda42c08b72550159b6a82051..0cf8efda13539b383d1f8a4a379326aea370441b 100644 (file)
@@ -71,3 +71,14 @@ NMake command line.  The gtk3-demo project files will also be updated with the
 appropriate dependent libraries linked in-please check that the project settings \r
 contain the correct .lib file names for your system, as they assume the most \r
 common names are used there.\r
+\r
+=========================\r
+Building the translations\r
+=========================\r
+Building translations is supported via Meson builds or via the Visual Studio projects,\r
+both of which require a working msgfmt.exe (from gettext-tools, a part of gettext) in the\r
+PATH, or for the Visual Studio projects, passed into the arguments in "InstallBuildsBase"\r
+in gtk3-build-defines.[props|vsprops] with MSGFMT=xxx.  For the Visual Studio projects, for\r
+this to work one needs to also supply a "INSTALL_TRANSLATIONS=1" (without the quotes)\r
+argument to the same "InstallBuildsBase" in the afore-mentioned property sheet.  Using\r
+msgfmt.exe from Cygwin or MSYS2 is supported as well.\r
index 26ab2186bab1f770d5ba8369e02decfbef9c31cf..d3fc362377b1c502c5fcc582f3842e6f43906f04 100644 (file)
@@ -42,6 +42,10 @@ GDBUS_CODEGEN = $(PREFIX)\bin\gdbus-codegen
 GLIB_COMPILE_SCHEMAS = $(PREFIX)\bin\glib-compile-schemas.exe
 !endif
 
+!ifndef MSGFMT
+MSGFMT = msgfmt
+!endif
+
 !if "$(PLAT)" == "x64"
 AT_PLAT=x86_64
 !elseif "$(PLAT)" == "arm64"
index 5fe35d8762778f7f45acb63cc8132abc56b0c66c..b39764727ae70162ad8bcc60c2934f8ce25b4fcb 100644 (file)
@@ -51,7 +51,13 @@ GTK_TYPE_BULITINS_H = .\vs$(VSVER)\$(CFG)\$(PLAT)\obj\gtk-$(GTK_API_VERSION)\gtk
 GTK_VERSION_H = .\vs$(VSVER)\$(CFG)\$(PLAT)\obj\gtk-$(GTK_API_VERSION)\gtk\gtkversion.h
 GTK_GENERATED_PUBLIC_H = $(GTK_TYPE_BULITINS_H) $(GTK_VERSION_H)
 
-all: install-bin install-headers install-data
+!ifdef INSTALL_TRANSLATIONS
+DATA_TARGETS = install-data install-translations
+!else
+DATA_TARGETS = install-data
+!endif
+
+all: install-bin install-headers $(DATA_TARGETS)
 
 # Copy the built files
 install-bin:
@@ -131,3 +137,9 @@ install-data:
        @for %x in (its loc) do @copy ..\gtk\gtkbuilder.%x $(PREFIX)\share\gettext\its
        @for %x in (rng) do @copy ..\gtk\gtkbuilder.%x $(PREFIX)\share\gtk-3.0
        @for %l in (de es fr zh) do @for %f in ($(BASE_BUILT_BIN_DIR)\%l.gresource) do @copy %f $(PREFIX)\share\gtk-3.0\emoji
+
+# Generate and install the translations
+install-translations:
+       @for %d in (po po-properties) do @for %l in (..\%d\*.po) do @if not exist $(PREFIX)\share\locale\%~nl\LC_MESSAGES\ md $(PREFIX)\share\locale\%~nl\LC_MESSAGES
+       @for %l in (..\po\*.po) do @$(MSGFMT) -c -v -o $(PREFIX)\share\locale\%~nl\LC_MESSAGES\gtk30.mo %l
+       @for %l in (..\po-properties\*.po) do @$(MSGFMT) -c -v -o $(PREFIX)\share\locale\%~nl\LC_MESSAGES\gtk30-properties.mo %l